/* CODES USED IN "Current Use of Cigarettes in the United States: The Joint Role of Race/Ethnicity and Health Insurance Coverage"
 by Julia N. Soulakova and Lisa J. Crockett; provisionally accepted for publication in Healthcare*/

/*EDIT the line below: Assign the library name CPS, this is the library where you store the data file SIX*/
LibName  CPS "C:\Users\ju594805\OneDrive - University of Central Florida\2018-19 TUS-CPS\." ;

/*run the format procedure below; note that some of these formats are not used in the paper*/
proc format;
value MUHtype_dif
1='Public'
2='private owned or rented including no cash rent'
;

value newage5f
    1='18-34'
    2='35-44'
    3='45-54'
    4='55+'
;
value AgeGrpf
1="18-24"
2="25-44"
3="45-64"
4="65+"
;
value marriedF
		1 = "Married (Spouse present or absent)"
		2 = "Not Married (widowed, divorced, or separated)"
		3 = "Never married";
	value employmentF
		1 = "Employed (at work or absent)"
		2 = "Unemployed"
		3 = "Not in labor force";
	Value Educ3F
		1 = "Below High School Diploma"
		2 = "High Sch Diploma/EQUIV"
		3 = "Some coll/BS or Grad degree";
	Value EducF
		1 = "Less than High School"
		2 = "High School (or equivalent)"
		3 = "Some College or Bachelor�s Degree"
		4 = "Graduate degree";
value smokstatf
    1='never'
    2='current smokers'
    3='former smokers'    ;

	Value TUSSmokStatF
		1 = "Never smoker"
		2 = "Everyday smoker"
		3 = "Some days smoker"
		4 = "Former smoker";
	
	value phone1F
		1 = "Phone"
		2 = "Personal";

value metstatf
    1='Metropolitan'
    2='Non-Metropolitan'
;

value newracef
    1='white'
    2='black'
    3='hispanic'
    4='other'
;

value newemplstatf
    1='working/Employed-at work/With job, not at work/Employed-absent'
    2='Unemployed-on layoff/Unemployed-looking for work'
    3='Not in labor force'
;

value NewEDUf
    1='high school or less, no diploma'
    2='high school diploma'
    3='some college, no degree'
    4='associate degree'
    5='bachelor or higher'
;

value incomef
    1='<$20,000'
    2='$20,000-39,999'
    3='$40,000-74,999'
    4='$75,000+'
;

value HEHOUSUTf
1='House, apt., flat'
2='HU in nontransient hotel, etc.'
3='HU, perm, in trans. hotel, motel, etc.'
4='HU in rooming house'
5='Mobile home or trailer with no permanent room added'
6='Mobile home or trailer with 1 or more perm rooms added'
7='HU not specified above Other Unit'
8='Qtrs not hu in rooming or boarding house'
9='Unit not perm in trans. hotel, motel, etc.'
10='Tent or trailer site'
11='Student quarters in college dormitory'
12='Other not HU'
;

value HUnitsf
1='1 unit'
2='2+ units'
;

value yesnof
1='Yes'
2='No'
;

value PEK4f
1='No one is allowed to smoke anywhere INSIDE YOUR HOME'
2='Smoking is allowed in some places or at some times INSIDE YOUR HOME'
3='Smoking is permitted anywhere INSIDE YOUR HOME'
;

value PEK5af
1='ALLOWED INSIDE ALL apartments or living areas'
2='ALLOWED INSIDE SOME apartments'
3='NOT ALLOWED at ALL inside apartments'
;

value PEK5bf
1='Allowed in ALL INDOOR COMMON areas'
2='Allowed in SOME INDOOR COMMON areas'
3='NOT allowed at ALL in ANY INDOOR COMMON areas'
;

value GEREGf
1='Northeast'
2='Midwest'
3='South'
4='West'
;

value sexf
1='male'
2='female'
;

value MUHtypef
1='Public'
2='private owned'
3='private rent including no cash rent'
;

value PEk4_R_dif
1='No one is allowed to smoke anywhere INSIDE YOUR HOME '
2='Smoking is permitted anywhere INSIDE YOUR HOME or Smoking is allowed in some places or at some times INSIDE YOUR HOME'
;

value PEk5a_R_dif
1='Smoking should not be NOT ALLOWED at ALL inside apartments'
2='Smoking should be ALLOWED INSIDE ALL apartments or living areas or ALLOWED INSIDE SOME apartments'
;

value PEK5b_R_dif
1='Smoking should NOT be allowed at ALL in ANY INDOOR COMMON areas'
2='Smoking should be allowed in ALL INDOOR COMMON areas or Allowed in SOME INDOOR COMMON areas'
;

value MUHtype_dif
1='Public'
2='private owned or rented including no cash rent'
;

value race_ethnf
1='NH White'
2='NH BAA'
3='NH AIAN'
4='NH Asian'
5='NH HPI'
6='NH Mult'
7='Hisp'
;
value race_ethn5f
1='NH White'
2='NH BAA'
3='NH AIAN'
4='NH OTHER:ASIAN,HPI,MULT'
7='Hisp'
;
value insurancef
    4='both, MCAID and MCARE, but no private'
    3='MCAID only and no priv'
    2='MCARE only and no priv'
    1='priv insur'
    0='No insur'
;

value insf
    4='both, MCAID and MCARE'
    3='MCAID only'
    2='MCARE only'
    1='pub other than MCAID/MCARE'
    0='No pub insur'
;

run;
/*read the dataset SIX to Work library*/
/*dataset SIX is a complete dataset for all study measures and includes six racial/ethnic groups*/ 
data six; set cps.six; run;
/*description of variables
current1 = indicator of current cigarette use, 1=current use, 0=non-use
NOW_PRIV = indicator of having private coverage
NOW_MCARE = indicator of having Medicare coverage 
NOW_MCAID = indicator of having Medicaid coverage
NOW_COV = indicator of having any coverage not limiting to private, Medicare and Medicaid

AgeGrp = age group 
PESex = biological sex 
race_ethn = race/ethnicity 
marstat = marital status 
educ = highest level of education  
income = family income 
GTMETSTA = metropolitan/nonmetropolitan area of residence, 1=metro, 2=nonmetro, 3=undefined 
GEREG = U.S. region of residence 
phone1 = TUS survey mode
dis1 =disability status: 1=yes, 0=mo
*/

/*Results presented in Results Section: 1st paragraph*/
proc surveyfreq data=six varmethod=BRR(fay=0.75);
Table current1 NOW_COV NOW_PRIV NOW_MCARE NOW_MCAID NOW_PRIV*NOW_MCARE NOW_MCARE*NOW_MCAID NOW_PRIV*NOW_MCAID; 
Weight SmplWgt;
REPWGT RepWgt1-RepWgt160;   
run;
/*Results presented in TABLE 1 */
proc surveyfreq data=six varmethod=BRR(fay=0.75);
Table AgeGrp PESex race_ethn marstat educ  income GEREG GTMETSTA dis1 phone1 NOW_PRIV NOW_MCARE NOW_MCAID ; 
Weight SmplWgt;
REPWGT RepWgt1-RepWgt160;   
run;

/*Results presented in TABLE 2 */
proc surveyfreq data=six varmethod=BRR(fay=0.75);
Table NOW_PRIV*current1 NOW_MCARE*current1 NOW_MCAID*current1 /row chisq; 
Weight SmplWgt;
REPWGT RepWgt1-RepWgt160;   
run;
proc surveyfreq data=six varmethod=BRR(fay=0.75);
Table race_ethn*NOW_PRIV*current1 /row chisq; 
Weight SmplWgt;
REPWGT RepWgt1-RepWgt160;   
run;
proc surveyfreq data=six varmethod=BRR(fay=0.75);
Table race_ethn*NOW_MCARE*current1 /row chisq; 
Weight SmplWgt;
REPWGT RepWgt1-RepWgt160;   
run;
proc surveyfreq data=six varmethod=BRR(fay=0.75);
Table race_ethn*NOW_MCAID*current1 /row chisq; 
Weight SmplWgt;
REPWGT RepWgt1-RepWgt160;   
run;

/*The model-assisted results presented in TABLE 3 and text*/
data wbh; set six; if race_ethn in (1,2,7);run; /*limiting to three racial/ethnic groups*/
/*final model, to run the initial model include race_ethn*NOW_MCAID*/ 
/*POSTHOC COMPARISONS for the Interaction term*/

PROC SURVEYLOGISTIC data=wbh varmethod=brr(fay=0.75); 
	class AgeGrp PESex race_ethn marstat(REF='Never married')  educ(REF=FIRST)  income(REF='$75,000+') GEREG GTMETSTA dis1(REF=FIRST) phone1 
          NOW_PRIV(REF=FIRST) NOW_MCAID(REF=FIRST) NOW_MCARE(REF=FIRST) /param=glm;
	model current1(REF=FIRST)= AgeGrp PESex race_ethn  marstat educ income GEREG GTMETSTA  dis1 phone1 
                               NOW_PRIV NOW_MCAID NOW_MCARE 
                               race_ethn*NOW_PRIV  race_ethn*NOW_MCARE /rsq GCONV=1E-12; 
	lsmeans race_ethn*NOW_PRIV /alpha=0.017 diff or cl; 
	Weight SmplWgt;
    REPWGT RepWgt1-RepWgt160;   
RUN;
/*POSTHOC COMPARISONS for the age group, education and income; alternatively could use lsmeans*/
PROC SURVEYLOGISTIC data=wbh varmethod=brr(fay=0.75); 
	class AgeGrp PESex race_ethn marstat(REF='Never married')  educ(REF=FIRST)  income(REF='$75,000+') GEREG GTMETSTA dis1(REF=FIRST) phone1 
          NOW_PRIV(REF=FIRST) NOW_MCAID(REF=FIRST) NOW_MCARE(REF=FIRST) /param=glm;
	model current1(REF=FIRST)= AgeGrp PESex race_ethn  marstat educ income GEREG GTMETSTA  dis1 phone1 
                               NOW_PRIV NOW_MCAID NOW_MCARE 
                               race_ethn*NOW_PRIV  race_ethn*NOW_MCARE /rsq alpha=0.017 GCONV=1E-12; 
	Weight SmplWgt;
    REPWGT RepWgt1-RepWgt160;   
RUN;
/*POSTHOC COMPARISONS for the marital status; alternatively could use lsmeans*/
PROC SURVEYLOGISTIC data=wbh varmethod=brr(fay=0.75); 
	class AgeGrp PESex race_ethn marstat(REF='Never married')  educ(REF=FIRST)  income(REF='$75,000+') GEREG GTMETSTA dis1(REF=FIRST) phone1 
          NOW_PRIV(REF=FIRST) NOW_MCAID(REF=FIRST) NOW_MCARE(REF=FIRST) /param=glm;
	model current1(REF=FIRST)= AgeGrp PESex race_ethn  marstat educ income GEREG GTMETSTA  dis1 phone1 
                               NOW_PRIV NOW_MCAID NOW_MCARE 
                               race_ethn*NOW_PRIV  race_ethn*NOW_MCARE /rsq alpha=0.025 GCONV=1E-12; 
	Weight SmplWgt;
    REPWGT RepWgt1-RepWgt160;   
RUN;









